#include "kernel.h"

Kernel::Kernel(QVector<moves_pair> moves)
{
    if(moves.size()>0)
        setGame(moves);
}

void Kernel::setGame(QVector<moves_pair> moves)
{
    m_gameMoves = moves;
}

bool Kernel::nextMove()
{
    if(size()>0)
    {
        moves_pair pair = m_gameMoves.first();
        m_gameMoves.pop_front();
        makeWhiteMove(pair.white);
        makeBlackMove(pair.black);
        return true;
    }
    return false;
}

int Kernel::size() const
{
    m_gameMoves.size();
}

bool Kernel::makeWhiteMove(chess_move c_move)
{
    return makeMove(c_move, true);
}

bool Kernel::makeBlackMove(chess_move c_move)
{
    return makeMove(c_move, false);
}

bool Kernel::makeMove(chess_move c_move, bool is_white)
{
    if(!c_move.is_correct)
        return false;

    switch(c_move.figure)
    {
    case pawn:
        return makePawnMove(c_move);
    };
}

bool Kernel::makePawnMove(chess_move c_move)
{
    if(c_move.figure != pawn)
        return false;

}
